﻿using System.Windows;
using SilverChart.Core.Configuration;
using SilverChart.Core.Service;

namespace SilverChart.Configuration.Converter {
    [ServiceProvider(LayzeCreation = true, ServiceName = "Default VerticalAlignment configuration converter", Singleton = true)]
    public class VerticalAlignmentConverter : ConfigurationConverter<VerticalAlignment> {
        public bool Convert(string input, out VerticalAlignment value) {
            switch (input.ToLower()) {
                case "bottom":
                case "b":
                    value = VerticalAlignment.Bottom;
                    break;
                case "center":
                case "c":
                    value = VerticalAlignment.Center;
                    break;
                case "top":
                case "t":
                    value = VerticalAlignment.Top;
                    break;
                case "stretch":
                case "s":
                    value = VerticalAlignment.Stretch;
                    break;
                default:
                    value = VerticalAlignment.Top;
                    return false;
            }
            return true;
        }
    }
}
